package com.keyancompany.zhongbaopingtai.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.listener.IClickCancleListener;
import com.keyancompany.zhongbaopingtai.model.BalanceHistoryModel;

/**
 * Created by firefox on 2016/6/15.
 */
public class BalanceHistoryAdapter extends ListAdapter<BalanceHistoryModel> {


    public BalanceHistoryAdapter(Context ctx) {
        super(ctx);
    }

    @Override
    public int getContentViewId() {
        return R.layout.item_balance_history;
    }

    @Override
    public HolderView getHoldView(int position, View contentView, ViewGroup parent) {
        BalanceHistoryHolder hold = new BalanceHistoryHolder();
        hold.money = (TextView) contentView.findViewById(R.id.balance_history_money);
        hold.time = (TextView) contentView.findViewById(R.id.balance_history_time);
        hold.type = (TextView) contentView.findViewById(R.id.balance_history_type);
        hold.content = (TextView) contentView.findViewById(R.id.balance_history_content);
        return hold;
    }

    @Override
    public void setItemView(final int position, HolderView contentView, BalanceHistoryModel item) {
        BalanceHistoryHolder hold = (BalanceHistoryHolder) contentView;
        hold.content.setText(TextUtils.isEmpty(item.getRemark()) ?
                ctx.getResources().getString(R.string.uninput_text) : item.getRemark());
        hold.time.setText(ctx.getString(R.string.jiaoyiTime, item.getCreateTime()));
        hold.type.setText(ctx.getString(R.string.jiaoyileixing, item.getSourceStr()));
        hold.money.setText(ctx.getString(R.string.jiaoyijine, "" + item.getMoney()));
    }

    class BalanceHistoryHolder extends HolderView {

        TextView type;

        TextView content;

        TextView time;

        TextView money;

    }

}
